const express = require('express')
const errorHandle = require('./middleware/error')
require('./model')
const cors= require('cors')

const app = express()
const router = require('./router')
app.use(express.json())
app.use(cors())
app.use('/uploads', express.static(__dirname + '/uploads'))
app.use('/admin', express.static(__dirname + '/admin'))

// 挂载路由
app.use('', router)

// 通用增删改查
require('./router/common')(app)

// 挂载同意处理的服务的错误
app.use(errorHandle())

app.listen('3000', () => {
	console.log('后台服务启动成功')
})